<template>
  <div class="mod-config">
<el-form :inline="true">

<!--  <el-form-item>-->
<!--    <el-button>测试查询</el-button>-->
<!--  </el-form-item>-->

</el-form>
  <el-table
    :data="dataList.slice((currentPage-1)*pageSize,currentPage*pageSize)"
    border
    :v-loading="dataListLoading"
    @selection-change="selectionChangeHandle"
    style="width: 100%;"
  >
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
    <el-table-column
      label="排程模型id"
      header-align="center"
      align="center"
      prop="_id"
    >
    </el-table-column>

    <el-table-column
      label="排程属性"
      header-align="center"
      align="center"
      prop="belong"
    >
    </el-table-column>

    <el-table-column
      label="排程效率"
      header-align="center"
      align="center"
      prop="efficiency"
    >
    </el-table-column>

    <el-table-column
      label="排程模型节点数"
      header-align="center"
      align="center"
      prop="nodeCount"
    >
    </el-table-column>


    <el-table-column
      label="操作"
      align="center"
      header-align="center"
    >
      <template slot-scope="scope">
        <el-button type="text" size="small" @click="editorHandle_qunee()">编辑排程</el-button>
        <el-button type="text" size="small" @click="deleteHandle(scope.row._id)">删除订单</el-button>
      </template>
    </el-table-column>








  </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-sizes="[10, 20, 50, 100]"
      :page-size.sync="pageSize"
      :total="dataList.length"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
<!--    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>-->

  </div>

</template>


<script>
export default {
  data () {
    return {
      dataForm: {
        key: ''
      },
      dataList: [],
      pageList: [],
      // 页面索引
      pageIndex: 1,
      // 每页显示数量
      pageSize: 10,
      currentPage: 1,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false
    }
  },
  // created:function () {
  //   printWorld()
  // },
  components: {

  },
  watch: {

  },

  activated () {
    this.getDataList()
  },
  methods: {
//* ***********************************************************************************************************************
    // 获取数据列表
    getDataList () {
      if (this.dataList !== []) {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/business/Project3/dataapstask/findAllModules'),
          method: 'get'
        }).then(({data}) => {
          if (data) {
            // 此处出现的既有元素索引又有元素的问题应该是前后端数据以及迭代变量的问题
            for (var i = 0; i < data.length; i++) {
              this.dataList.push(data[i])
            }
            console.log(this.dataList)
          } else {
            this.dataList = []
          }
        })
        this.dataListLoading = false
      } else {
        // eslint-disable-next-line no-undef
        this.pageList = this.dataList.slice((this.currentPage - 1) * pageSize, this.currentPage * pageSize)
      }
    },

    handleSizeChange: function (Size) {
      this.pageSize = Size
      // this.handleCurrentChange(1);
    },
    handleCurrentChange: function (currentPage) {
      this.currentPage = currentPage
    },

    deleteHandle (_id) {

    },
    selectionChangeHandle (val) {
      this.dataListSelections = val
    },
    editorHandle_qunee () {

    }

  }
}
</script>
